<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="vlms.bean.Movie"%>
<%@ page import="java.text.*"%>
<%@ page import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
Movie movie=(Movie)request.getAttribute("movie");
System.out.println("here");
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">

function validate(){
    
    if(document.frm.movieName.value=="")
    {
 alert("Please enter movie name");
 document.frm.movieName.focus();
 return false;
    }
    if(document.frm.movieBanner.value=="")
    {
 alert("Please enter movie banner");
 document.frm.movieBanner.focus();
 return false;
    }
    if(document.frm.releaseDate.value=="")
    {
 alert("Please enter release date");
 document.frm.releaseDate.focus();
 return false;
    }
    if(document.frm.rentAmount.value=="")
    {
 alert("Please enter rent amount");
 document.frm.rentAmount.focus();
 return false;
    }
   
    if(document.frm.categories.value=="")
    {
 alert("Please select a category");
 document.frm.categories.focus();
 return false;
    }
    
    	 
    if(document.frm.state.value=="")
   {
 alert("Please enter state");
 document.frm.state.focus();
 return false;
    }
    if(document.frm.copiesAvailable.value=="")
    {
 alert("Please enter copiesAvailable");
 document.frm.city.focus();
 return false;
    }
   
    return true;
}
    </script>

<title>UpdateMovie</title>
</head>
<body>
<table width="100%">
<%@ include file="/header.jsp" %>

<tr valign="top"><td align="center" height="300px">
<table width="100%" border="1">

<tr valign="top" height="50px">
<td align="center">
<%@ include file="/headerLinks.jsp" %>
</td>
</tr>
<tr><td align="center" height="40px" colspan="2" valign="top"><h3>Search and Delete a Movie</h3></td></tr>
<% if(request.getAttribute("message") != null) { %>
<tr><td align="center" style="color:red"><%= request.getAttribute("message") %></td></tr>
<% } %>
<tr>
<td>
<table>
<tr>
<td>



<FORM NAME="frm" METHOD="post" action="HandleUpdateMovie" onsubmit="return validate();">

					<h1>
						<INPUT TYPE="hidden" NAME="id" name="id" value='<%= movie.getMovieid()%>'>
					</h1>
					<H1 align="center">Update Movie</H1>
					<BR>
					<TABLE ALIGN="CENTER" width="400px">

						<TR>
							<TD><b>Movie Name</b></TD>
							<TD><INPUT TYPE="TEXT" NAME="movieName" id="moviename"
								value="<%= movie.getMoviename()%>"></TD>
						</TR>
						<TR>
							<TD><b>Banner</b></TD>
							<TD><INPUT TYPE="TEXT" NAME="movieBanner" id="movieBanner"
								value="<%= movie.getMoviebanner()%>"></TD>
						</TR>
						<% Calendar c= movie.getReleasedate();
					java.util.Date d=new java.util.Date(c.getTimeInMillis());
					
					
					%>
						<TR>
							<TD><b>Release Date (yyyy-mm-dd)</b></TD>
							<TD><INPUT TYPE="TEXT" NAME="releaseDate" id="releaseDate"
								value='<%=new SimpleDateFormat("yyyy-mm-dd").format(d)%>'></TD>
						</TR>
						<TR>
						<TR>
							<TD><b>Rent Amount</b></TD>
							<TD><INPUT TYPE="TEXT" NAME="rentAmount" id="rentAmount"
								value="<%= movie.getRentamount()%>"></TD>
						</TR>
						<TR>
						<% String category= movie.getCategory();
					    %>
						<TR>
							<TD><b>Categories</b></TD>
							<% if(category.equals("HORROR")) 
							{
							%>
							<TD><select name="categories" >
									<option value="HORROR" selected="selected">HORROR</option>
									<option value="ACTION">ACTION</option>
									<option value="HINDI">HINDI</option>
									<option value="ENGLISH">ENGLISH</option>
									<option value="COMEDY">COMEDY</option>
									<option value="ROMANTIC">ROMANTIC</option>
								</select>
							</TD>
							<%
							}
							%>
							
							<% 
							if(category.equals("ACTION")) 
							{
							%>
							<TD><select name="categories">
									<option value="HORROR">HORROR</option>
									<option value="ACTION" selected="selected">ACTION</option>
									<option value="HINDI">HINDI</option>
									<option value="ENGLISH">ENGLISH</option>
									<option value="COMEDY">COMEDY</option>
									<option value="ROMANTIC">ROMANTIC</option>
								</select>
							</TD>
							<%
							}
							%>
							
							<% if(category.equals("HINDI")) 
							{
							%>
							<TD><select name="categories">
									<option value="HORROR">HORROR</option>
									<option value="ACTION">ACTION</option>
									<option value="HINDI" selected="selected">HINDI</option>
									<option value="ENGLISH">ENGLISH</option>
									<option value="COMEDY">COMEDY</option>
									<option value="ROMANTIC">ROMANTIC</option>
								</select>
							</TD>
							<%
							}
							%>
							
							<% if(category.equals("ENGLISH")) 
							{
							%>
							<TD><select name="categories">
									<option value="HORROR">HORROR</option>
									<option value="ACTION">ACTION</option>
									<option value="HINDI">HINDI</option>
									<option value="ENGLISH" selected="selected">ENGLISH</option>
									<option value="COMEDY">COMEDY</option>
									<option value="ROMANTIC">ROMANTIC</option>
								</select>
							</TD>
							<%
							}
							%>
							
							<% if(category.equals("COMEDY")) 
							{
							%>
							<TD><select name="categories">
									<option value="HORROR">HORROR</option>
									<option value="ACTION">ACTION</option>
									<option value="HINDI">HINDI</option>
									<option value="ENGLISH">ENGLISH</option>
									<option value="COMEDY" selected="selected">COMEDY</option>
									<option value="ROMANTIC">ROMANTIC</option>
								</select>
							</TD>
							<%
							}
							%>
							
							<% if(category.equals("ROMANTIC")) 
							{
							%>
							<TD><select name="categories">
									<option value="HORROR">HORROR</option>
									<option value="ACTION">ACTION</option>
									<option value="HINDI">HINDI</option>
									<option value="ENGLISH">ENGLISH</option>
									<option value="COMEDY">COMEDY</option>
									<option value="ROMANTIC" selected="selected">ROMANTIC</option>
								</select>
							</TD>
							<%
							}
							%>
							
						</TR>
						<TR>
							<TD><b>Copies Available</b></TD>
							<TD><INPUT TYPE="TEXT" NAME="copiesAvailable" id="copiesAvailable" value='<%= movie.getCopiesavailable()%>'>
							</TD>
						</TR>

						<TR>
							<TD colspan=3 align="center"><INPUT TYPE="Submit"
								NAME="submit" VALUE="Update Movie"></TD>
						</TR>
					</TABLE>
				</FORM>


</td>
</tr>
	
</table>
</td>
</tr>
<%@ include file="/bottom.html" %>
</table>
</body>
</html>